# Maintainer: Thomas Bächler <thomas@archlinux.org>

pkgname=intel-ucode
pkgver=20180807.a
# Some random "download id" that intel has in their downloadcenter
_dlid=28087
pkgrel=1
pkgdesc='Microcode update files for Intel CPUs'
arch=('any')
url='https://downloadcenter.intel.com/SearchResult.aspx?lang=eng&keyword=processor%20microcode%20data%20file'
replaces=('microcode_ctl')
makedepends=('iucode-tool')
license=('custom')
source=("https://downloadmirror.intel.com/${_dlid}/eng/microcode-${pkgver/./}.tgz")
sha256sums=('46ab18699ec42eb6cc01ee1846ec4d7ca979766dee2156f92d69e2f6df548137')

build() {
  cd "$srcdir"

  rm -f intel-ucode{,-with-caveats}/list
  mkdir -p kernel/x86/microcode
  iucode_tool -w kernel/x86/microcode/GenuineIntel.bin intel-ucode{,-with-caveats}/
  echo kernel/x86/microcode/GenuineIntel.bin | bsdcpio -o -H newc -R 0:0 > intel-ucode.img
}

package() {
  cd "$srcdir"

  install -D -m0644 intel-ucode.img "${pkgdir}"/boot/intel-ucode.img
  install -D -m0644 license "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
